﻿using System;
using System.Linq;
using NHibernate;
using NHibernate.Linq;
using music.domain.Model;

namespace music.domain.Services
{
	public static class AccountService
	{
		public static Guid InitCurrentUser(ISession session, string login)
		{
			User user = session.Query<User>().FirstOrDefault(u => u.Login == login);

			if (user == null)
			{
				user = new User { Login = login };
				session.Save(user);
				session.Flush();
			}

			return user.Id;
		}
	}
}
